package domain;

import java.util.Date;
import java.util.Objects;

/**
 * 申请类
 *
 * @author liujiale
 */
public class Application {

    /**
     * 申请状态
     * status=waiting   待审
     * status=pass      通过
     * status=refuse    拒绝
     */
    /** 待审状态 */
    public static final int waiting = 0;

    /** 通过状态 */
    public static final int pass = 1;

    /** 拒绝状态 */
    public static final int refuse = -1;

    /** 申请时间 */
    private Date applicationTime;

    /** 申请人 */
    private StudentAccount applicant;

    /** 申请状态 */
    private int status;

    /** 描述 */
    private String description;


    /**
     * 空构造函数
     */
    public Application() {
    }

    /**
     * 构造函数
     *
     * @param applicationTime 申请时间
     * @param applicant       申请人
     * @param status          申请状态
     * @param description     描述
     */
    public Application(Date applicationTime, StudentAccount applicant, int status, String description) {
        this.applicationTime = applicationTime;
        this.applicant = applicant;
        this.status = status;
        this.description = description;
    }

    /**
     * 构造函数
     *
     * @param applicationTime 申请时间
     * @param status          申请状态
     * @param description     描述
     */
    public Application(Date applicationTime, int status, String description) {
        this.applicationTime = applicationTime;
        this.status = status;
        this.description = description;
    }

    /**
     * Gets application time.
     *
     * @return the application time
     */
    public Date getApplicationTime() {
        return applicationTime;
    }

    /**
     * Sets application time.
     *
     * @param applicationTime the application time
     */
    public void setApplicationTime(Date applicationTime) {
        this.applicationTime = applicationTime;
    }

    /**
     * Gets applicant.
     *
     * @return the applicant
     */
    public StudentAccount getApplicant() {
        return applicant;
    }

    /**
     * Sets applicant.
     *
     * @param applicant the applicant
     */
    public void setApplicant(StudentAccount applicant) {
        this.applicant = applicant;
    }

    /**
     * Gets status.
     *
     * @return the status
     */
    public int getStatus() {
        return status;
    }

    /**
     * Sets status.
     *
     * @param status the status
     */
    public void setStatus(int status) {
        this.status = status;
    }

    /**
     * Gets description.
     *
     * @return the description
     */
    public String getDescription() {
        return description;
    }

    /**
     * Sets description.
     *
     * @param description the description
     */
    public void setDescription(String description) {
        this.description = description;
    }

    @Override
    public boolean equals(Object o) {
        if (this == o) {
            return true;
        }
        if (!(o instanceof Application)) {
            return false;
        }
        Application that = (Application) o;
        return status == that.status && Objects.equals(applicationTime, that.applicationTime) && Objects.equals(applicant, that.applicant) && Objects.equals(description, that.description);
    }

    @Override
    public int hashCode() {
        return Objects.hash(applicationTime, applicant, status, description);
    }

    @Override
    public String toString() {
        return "Application{" +
                "applicationTime=" + applicationTime +
                ", applicant=" + applicant +
                ", status=" + status +
                ", description='" + description + '\'' +
                '}';
    }
}
